package util;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import entity.Metrics;

public class CsvWriter {
	public static void write(String name, Map<String,String> traindataMap) throws IOException{
		write(name,traindataMap,null);
	}
	public static void write(String name, Map<String,String> traindataMap,String condition) throws IOException{
				File file = new File(name);
		      // creates the file
		      file.createNewFile();
		      
		      
		      FileWriter writer = new FileWriter(file);
		      
		   // Writes the content to the file
		     
		      
		      
		      for(Entry<String,String> row : traindataMap.entrySet()){
		    	  
		    	  if(condition!=null){
			    	  if(row.getKey().contains(condition)){
			    		  writer.write(row.getKey()+","+row.getValue()); 
			    	  }
			      }else{
			    	  writer.write(row.getKey()+","+row.getValue()); 
			      }
		    	  
		      }
		      
		      
		      writer.flush();
		      writer.close();		
		}
	
}
